//
//  OrderTableViewCell.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/9/11.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//

#import "OrderTableViewCell.h"
#import "BLHeader.h"
#import "BLOrder.h"

@interface OrderTableViewCell ()
@property (weak, nonatomic) IBOutlet UILabel *orderThemeLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderStateLabel;

@property (weak, nonatomic) IBOutlet UILabel *orderTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *orderDetailBtn;
@property (weak, nonatomic) IBOutlet UILabel *orderPriceLabel;
@property (weak, nonatomic) IBOutlet UIView *redPoint;

@end

@implementation OrderTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.orderDetailBtn.layer.cornerRadius = 3;
    self.orderDetailBtn.layer.borderWidth = 1;
    self.orderDetailBtn.layer.borderColor = kAppThemeColor.CGColor;
    self.orderDetailBtn.layer.masksToBounds = YES;
    
    self.redPoint.layer.cornerRadius = 5;

}

- (void)setupUI:(BLOrder *)order {
    self.orderThemeLabel.text = order.orderTitle;
    self.orderTimeLabel.text = order.orderTime;
    self.orderPriceLabel.text = [NSString stringWithFormat:@"￥%@",order.orderPrice];
    
    switch ([order.orderState integerValue]) {
        case 1:// 已下单
            self.orderStateLabel.text = @"已下单";
            self.orderStateLabel.textColor = [UIColor blackColor];
            break;
        case 2:// 已接单
            self.orderStateLabel.text = @"已接单";
            self.orderStateLabel.textColor = [UIColor blackColor];
            break;
        case 3:// 待支付
            self.orderStateLabel.text = @"已付款";
            self.orderStateLabel.textColor = [UIColor blackColor];
            break;
        case 4:// 已支付
            self.orderStateLabel.text = @"已完成";
            self.orderStateLabel.textColor = [UIColor redColor];
            break;
        case -1:// 已拒绝
            self.orderStateLabel.text = @"已拒单";
            self.orderStateLabel.textColor = [UIColor grayColor];
            break;
            
        default:
            break;
    }
    NSMutableDictionary *dic = [[NSUserDefaults standardUserDefaults] objectForKey:@"userDic"];
    if ([dic objectForKey:order.orderCode]) {
        [self.redPoint setHidden:NO];
    }else {
        [self.redPoint setHidden:YES];
    }
}

@end
